package com.hylink.util;

import org.apache.commons.lang3.StringUtils;

/**
 * Created by ryl on 2017/6/12 0012.
 */
public class escapeWord {

    /**
     * 转义正则特殊字符 （$()*+.[]?\^{},|）
     *
     * @param keyword
     * @return
     */
    public static Object escapeExprSpecialWord(String keyword) {
        if (StringUtils.isNotBlank(keyword)) {
          //  String[] fbsArr = { "\\","%","_", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" };
            String[] fbsArr = { "\\","%","_","％" };

            for (String key : fbsArr) {
                if (keyword.contains(key)) {
                    keyword = keyword.replace(key, "\\" + key);
                }
            }
        }
        return keyword;
    }
}
